﻿using System;
using System.Collections.Generic;
using System.Data.Entity;

using CrudServices;
using CrudServices.EF;

namespace TestClient
{
    internal static class Program
    {
        private static void Main(string[] args)
        {
            //Server-side
            Database.SetInitializer<ExpenseTrackerContext>(null);
            var service = new CrudServiceEF<ExpenseTrackerContext>();

            //Client-side
            var client = new CrudClient(service);
            IEnumerable<CategoryDto> categories = client.Search<CategoryDto>(SearchCriteriaBuilder
                .From<Category>()
                .OrderBy(c => c.Description)
                .OrderByDescending(c => c.Name)
                .Select<CategoryDto>());
            foreach (CategoryDto category in categories)                
                Console.WriteLine(category.Name);
            Console.Read();
        }
    }
}